/*
 * Background Flickr: Copyright (C) 2009  Craig McNicholas
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.ddw.app.bflickr.flickr.api.response;

import com.ddw.app.bflickr.flickr.api.FlickrResponse;
import com.ddw.app.bflickr.logging.Log;
import com.ddw.app.bflickr.logging.LogFactory;

/**
 * Abstract class for flickr api responses. This class should not be used 
 * directly instead use classes which inherit from it.
 * @author craig
 *
 */
public abstract class FlickrApiResponse implements FlickrResponse {

	private Log log = LogFactory.createInstance(this.getClass());
	private FlickrResponseErrorCode responseCode = FlickrResponseErrorCode.UNKNOWN;
	
	@Override
	public FlickrResponseErrorCode getResponseCode() {
		return this.responseCode;
	}
	
	/**
	 * Set the flickr response code from the request
	 * @param code the code to set from the request
	 */
	public void setResponseCode(FlickrResponseErrorCode code) {
		if(code == null) { 
			log.error("The response code cannot be null");
			throw new IllegalArgumentException("The response code cannot be null");
		}
		this.responseCode = code;
	}

}
